import { param2Obj } from '@/utils'

const userMap = {
  admin: {
    "username": "admin",
    "api_token": "xxxx"
  },
  editor: {
    "username": "editor",
    "api_token": "xxxx"
  }
}

export default {
  loginByUsername: config => {
    const { username } = JSON.parse(config.body)
    return userMap[username]
  },
  getUserInfo: config => {
    return {
      "id": 1,
      "username": "admin",
      "password": "xxxx",
      "api_token": "xxxx",
      "remember_token": null,
      "created_at": "2018-11-06 18:17:04",
      "updated_at": "2018-11-06 18:17:04",
      "roles": [
      "admin"
      ]
    }
    // const { token } = param2Obj(config.url)
    // if (userMap[token]) {
    //   return userMap[token]
    // } else {
    //   return false
    // }
  },
  logout: () => 'success'
}
